package com.mt.mtyx.mq.service;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 消息队列业务层
 *
 * @author WMT
 * @Date 2023/7/21 19:05
 */
@Service
public class RabbitMqService {

    @Autowired
    private RabbitTemplate rabbitTemplate;

    /**
     * 发送消息
     *
     * @param exchange 交换机
     * @param routingKey 路由键
     * @param message 消息
     * @return 成功
     */
    public boolean sendMessage(String exchange, String routingKey, Object message) {
        rabbitTemplate.convertSendAndReceive(exchange, routingKey, message);
        return true;
    }
}
